package Offer2018;

/**
 * 合并两个排序的链表
 * Created by 雷文康 on 2018/3/4.
 */
public class Test17 {
    public static ListNode mergeListNode(ListNode head1, ListNode head2) {
        if (head1 == null){
            return head2;
        }
        if (head2 == null) {
            return head1;
        }
        ListNode head;
        if (head1.value < head2.value) {
            head = head1;
            head.next = mergeListNode(head1.next, head2);
        } else {
            head = head2;
            head.next = mergeListNode(head1, head2.next);
        }
        return head;
    }

}
